<%@page import="hyl.core.MyFun"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%><%@ include file="pub/top.jsp"%>
<%@ page import="java.util.List,java.util.Map"%>
<%
String aname = "";
	aname = request.getParameter("aname");

int state = 200;
if (request.getParameter("state") != null && !request.getParameter("state").isEmpty()) {
	state = MyFun.str2int(request.getParameter("state"));
}
%>
<!-- 全局变量 函数定义区 -->
<%!%>
<!-- 实例变量 函数定义区 -->
<%
//网页title
String JSPTITLE = "应用管理";
%>
<%@ include file="pub/head.jsp"%>
<!-- 样式添加区 -->
<link rel="stylesheet" href="<%=basePath%>DataTables/datatables.min.css">
<!-- 下右内容区 -->
<div id="outerdiv"
	style="position: fixed; top: 0; left: 0; background: rgba(0, 0, 0, 0.7); z-index: 999; width: 100%; height: 100%; display: none;">
	<div id="innerdiv" style="position: absolute;">
		<img id="bigimg" style="border: 5px solid #fff;" src="" />
	</div>
</div>

<div class="main-content-inner">
	<div class="breadcrumbs ace-save-state" id="breadcrumbs">
		<ul class="breadcrumb">
			<li><i class="ace-icon fa fa-home home-icon"></i>第三方应用管理</li>
			<li class="active"><%=JSPTITLE%></li>
		</ul>
	</div>
	<div class="page-content">
		<!-- page-header{ -->
		<div class="page-header">
			<!-- table header1{ -->
			<div class="row">
				<div class="col-xs-12">
					<div class="clearfix">
						<div class="pull-right tableTools-container"></div>
						<div class="">
							<div class="btn-group" style="margin-top: 5px">
								<a href="#" class="btn-refresh btn  btn-xs "> <i
									class="im-spinner10 fa-spin"></i> 刷新
								</a> <a data-toggle="collapse" href="#demo" class=" btn  btn-xs ">
									<i class="im-spinner10 fa-spin"></i>搜索
								</a>
							</div>
						</div>
					</div>
					<div id="demo" class="panel-collapse collapse ">
						<div class="panel-body well">
							<form>
								<div class="col-lg-12 col-sm-12  input-group ">
									<span class="input-group-addon"> <i
										class="fa fa-calendar"></i>
									</span> <input type="text" name="aname" value="<%=aname%>"
										placeholder="应用名称"> &nbsp&nbsp 状态： <select
										name="state">
										<option value=200 <%if (state == 200) {%> selected <%}%>>审核中</option>
										<option value=220 <%if (state == 220) {%> selected <%}%>>通过</option>
										<option value=202 <%if (state == 202) {%> selected <%}%>>拒绝</option>
									</select>
								</div>
								<div class="col-lg-12 col-sm-12">
									<button type="submit"
										class="btn btn-success btn-sm  pull-right">
										<span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
										查找
									</button>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
			<!-- }table -header1  -->
		</div>
		<!-- }page-header  -->

		<!-- table header2{ -->
		<div class="row">
			<div class="col-xs-9 tablehead2L"></div>
			<div class="col-xs-3 tablehead2R"></div>
		</div>
		<!-- }table -header2  -->
		<!--  table { -->
		<div class="row tablexscroll">
			<table id="myTable" class="table table-striped table-bordered"
				cellspacing="0">
				<thead>
					<tr>
					</tr>
				</thead>
				<tbody>
				</tbody>
			</table>

		</div>
		<!--}table  -->
		<!-- table end{ -->
		<div class="row">
			<div class="col-xs-4"></div>
			<div class="col-xs-8">
				<ul class="pagination"></ul>
				<span class="tablefooterinfo"></span>
			</div>
		</div>
		<!--}table end -->
	</div>
</div>
<!--  footer{ -->
<div class="footer">
	<div class="footer-inner">
		<div class="footer-content  pull_right">
			<span class="bigger-110"> <span class="blue bolder"></span>
			</span>
		</div>
	</div>
</div>
<!--}  footer -->

<a href="#" id="btn-scroll-up"
	class="btn-scroll-up btn btn-sm btn-inverse"> <i
	class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
</a>

<%@ include file="pub/bottom.jsp"%>


<!-- 引入组件库 -->
<script src="<%=basePath%>DataTables/datatables.min.js"></script>
<script src="<%=basePath%>js/hyl.page.js"></script>
<!-- 自定义脚本 加载区 -->
<script>
const JSPTITLE='<%=JSPTITLE%>';
const BASEPATH='<%=basePath%>';
	//console.log(BASEPATH + "admin/Dao/app_1.jsp");

function fl(id, state) {
	alert(state);
	$.ajax({
		type : 'get',
		url : BASEPATH + 'admin/Dao/app_2.jsp',
		data : {
			"state" : state,
			"id" : id
		},
		success : function(data) {
			alert("更新成功");
			window.location.reload();
		}
	});
}
function xg(id) {
	window.open(BASEPATH + 'admin/app_xg.jsp?id=' + id);
}
var confg = {
	dom : '',
	renderer : "bootstrap",
	paging : false,
	"ordering" : false,
	"searching" : false,
	"info" : false,
	buttons : [ 'colvis', 'pdf', {
		text : 'My button',
		action : function(dt) {
			console.log('My custom button!');
		}
	} ],
	//stateSave: true, 
	"language" : {
		"lengthMenu" : "每页 _MENU_ 条记录",
		"zeroRecords" : "没有找到记录",
		"info" : "第 _PAGE_ 页 ( 总共 _PAGES_ 页 )",
		"infoEmpty" : "无记录",
		"infoFiltered" : "(从 _MAX_ 条记录过滤)"
	//, "decimal": ".", "thousands": "," ,
	},
	//列属性声明

	//a.t0,a.t1,a.t2,a.tm0,a.dt0
	//,a.s0,a.t3,a.id,a.appid
	//render 渲染特定列
	"columnDefs" : [
			{
				title : "logo",
				"render" : function(data, type, row) {
					var img = ''
					if (row[3] != null && row[3] != "") {
						img = '<img  width=80 height=50 src=\"'
							+ row[3]+ '\">';
					}
					return img;
				},
				"targets" : 0
			},
			{
				title : "app名称",
				"render" : function(data, type, row) {									
					return  row[0];
				},
				"targets" : 1
			},{
				title : "app备注",
				"render" : function(data, type, row) {
					
					return nvlStr(row[9]);
				},
				"targets" : 2
			},
			{
				title : "负责人",
				"render" : function(data, type, row) {
					return row[1];
				},
				"targets" : 3
			},
			{
				title : "手机",
				"render" : function(data, type, row) {
					return nvlStr(row[2]);
				},
				"targets" : 4
			},
			{
				title : "app域名",
				"render" : function(data, type, row) {
					return nvlStr(row[6]);
				},
				"targets" : 5
			},
			{
				title : "注册时间",
				"render" : function(data, type, row) {
					return row[4] != null ? fmtTime(row[4]) : "";
				},
				"targets" : 6
			},
			{
				title : "认证状态",
				"render" : function(data, type, row) {
					var state = "认证中";
					if (row[5] == 2) {
						state = "已通过";
					} else if (row[5] == 0) {
						state = "已拒绝";
					}
					return state;
				},
				"targets" : 7
			},
			{
				title : "操作",
				"render" : function(data, type, row) {
					var id = row[7];
					//alert(flowid);
					var button = '<button class="btn btn-sm btn-success btn-white btn-round " onclick="xg('
							+ id + ')">修改</button>';
					if (row[5] == 1) {
						button += '<button class="btn btn-sm btn-success btn-white btn-round " onclick="fl('
								+ id
								+ ',2)">通过</button>'
								+ '<button class="btn btn-sm btn-success btn-white btn-round " onclick="fl('
								+ id + ',0)">拒绝</button>';
					}
					return button;
				},
				"targets" : 8
			} ],
	"footerCallback" : function(row, data, start, end, display) {
		//汇总统计回调函数

	}
};
$(document).ready(
	function() {
		var table = $('#myTable').DataTable(confg);
		//自定义的分页的函数,名字不要改 确保与page.js中的调用函数名一致;
		//载入数据的函数
		//传入第几页
		var PG = HylPage.getInstance(JSPTITLE);
		PG.load = function(n) {
			var pgindex = PG.sessionPgIndex();//缓存成上一次定位的页
			if (pgindex && (!n))
				n = pgindex;
			else if ((!pgindex) && (!n)) {
				n = 1;
			}
			//需要传到后台的参数 	
			var data1 = {
				"rs_index" : (n - 1) * PG.pgSize,//从第几条记录开始
				"rs_size" : PG.getMaxRcNum(),//取几条数据过来
				"aname" : $("input[name='aname']").val(),
				"state" : $("input[name='state']").val()
			};
			//用法: $.post("chargelist2.do", data1).success(function(rs) {});    	
			//解释: (去哪里,要做什么) 成功做完成以后{
			// 返回以后 做什么...
			//}
		
			$.post(BASEPATH + "admin/Dao/app_1.jsp", data1)
				.success(
				function(result) {				
					PG.bind({
						tableobj : table,
						pageobj : $(".pagination"),
						rs : result.BODY._rs,
						pindex : n,
						psize : 0,
						totalnum : result.BODY.total
					});
					if (result.BODY.total
							&& result.BODY.total > 0) {
						$(".tablefooterinfo").html(
								"一共查询到" + result.BODY.total
										+ "条记录");
					}
				
				});
		}
		PG.load();
		//行点击事件
		$('#myTable tbody').on('click', '.btn-del', function() {
			var qtr = $(this).parent('tr');
			var data = table.row(qtr.get(0)).data();
			//alert('You clicked on ' + data[0] + '\'s row');
		});
		$('#myTable tbody').on('click', '.btn-chg', function() {
			var qtr = $(this).parent('tr');
			var data = table.row(qtr.get(0)).data();
			//alert('You clicked on ' + data[0] + '\'s row');
		});
	});
function Iclick(obj) {
	var _this = $(obj);//将当前的pimg元素作为_this传入函数  
	imgShow("#outerdiv", "#innerdiv", "#bigimg", _this);
}

function imgShow(outerdiv, innerdiv, bigimg, _this) {
	var src = _this.attr("src");//获取当前点击的pimg元素中的src属性
	$(bigimg).attr("src", src);//设置#bigimg元素的src属性

	/*获取当前点击图片的真实大小，并显示弹出层及大图*/
	$("<img/>").attr("src", src).load(function() {
		var windowW = $(window).width();//获取当前窗口宽度
		var windowH = $(window).height();//获取当前窗口高度
		var realWidth = this.width;//获取图片真实宽度
		var realHeight = this.height;//获取图片真实高度
		var imgWidth, imgHeight;
		var scale = 0.8;//缩放尺寸，当图片真实宽度和高度大于窗口宽度和高度时进行缩放 

		/*判断图片高度
		如大于窗口高度，图片高度进行缩放
		等比例缩放宽度*/ 
		if (realHeight > windowH * scale) {
			imgHeight = windowH * scale;
			imgWidth = imgHeight/realHeight*realWidth;				
			//如宽度扔大于窗口宽度  
			if (imgWidth > windowW * scale) {
				//再对宽度进行缩放  
				imgWidth = windowW * scale;
			}
		} else if (realWidth > windowW * scale) {

			/*
			如图片高度合适，判断图片宽度  
			如大于窗口宽度，图片宽度进行缩放  
			等比例缩放高度*/
			imgWidth = windowW * scale;
			imgHeight = imgWidth / realWidth * realHeight;
		} else {
			//如果图片真实高度和宽度都符合要求，高宽不变  
			imgWidth = realWidth;
			imgHeight = realHeight;
		}
		$(bigimg).css("width", imgWidth);
		//以最终的宽度对图片缩放  
		// 计算图片与窗口左边距
		// 计算图片与窗口上边距
		var w = (windowW - imgWidth) / 2;
		var h = (windowH - imgHeight) / 2;
		$(innerdiv).css({
			"top" : h,
			"left" : w
		});//设置#innerdiv的top和left属性  
		$(outerdiv).fadeIn("fast");//淡入显示#outerdiv及.pimg  
	});

	$(outerdiv).click(function() {//再次点击淡出消失弹出层  
		$(this).fadeOut("fast");
	});
}
</script>
